import java.util.List;

/**
 * @author 兴趣使然黄小黄
 * @version 1.0
 * @date 2023/3/16 21:30
 * 用于测试
 */
@SuppressWarnings({"all"})
public class JDBCTest {

    public static void main(String[] args) {
        // 先在student表中插入一些数据
        StudentDao studentDao = new StudentDao();
        studentDao.insertOne(new Student(1, "小黄"));
        studentDao.insertOne(new Student(2, "琪琪"));
        studentDao.insertOne(new Student(3, "七七"));
        // 查询
        System.out.println("================ 第一次查询 =================");
        List<Student> studentList = studentDao.selectAll();
        myPrint(studentList);
        // 删除 id 为1的
        System.out.println("================ 删除id = 1的后 =================");
        studentDao.deleteById(1);
        studentList = studentDao.selectAll();
        myPrint(studentList);
        // 修改 id 为2的
        System.out.println("================ 修改id = 2的后 =================");
        studentDao.updateById(2, "蒲公英");
        studentList = studentDao.selectAll();
        myPrint(studentList);
    }

    private static void myPrint(List<Student> studentList) {
        for (Student s : studentList) {
            System.out.println(s.getId() + " : " + s.getName());
        }
    }
}
